package com.aruba.test;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;

import java.util.Timer;
import java.util.TimerTask;

public class MainActivity extends AppCompatActivity {

    private EcgDrawingGraphView ecgDrawingGraphView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ecgDrawingGraphView = findViewById(R.id.ecg);
        ecgDrawingGraphView.setDrawing(true);
        ecgDrawingGraphView.reset();

        startTime();
    }

    private void startTime() {
        new Timer().schedule(new TimerTask() {
            @Override
            public void run() {
                double[] data = new double[]{
                        2,3,4,5,7,9,11,12,14,17,19,21,24,26,29,32,34,37,39,41,44,46,48,51,53,55,57,59,62,64,66,68,70,72,74,76,78,80,81,83,84,85,87,87,88,89,90,90,90,90,90,89,89,89,89,88,87,86,85,84,83,82,81,80,78,76,75,73,71,70,68,66,65,63,62,60,58,57,55,53,52,50,49,48,47,46,44,43,41,40,39,38,37,35,35,34,33,32,31,31,31,31,30,30,30,30,29,29,29,29,29,29,29,30,30,31,31,32,32,33,33,33,33,34,34,34,34,34,34,34,34,34,33,33,33,33,32,32,32,32,31,31,31,30,30,29,29,28,28,27,27,27,27,26,26,25,25,24,24,24,24,24,23,23,22,22,21,21,20,20,19,19,18,18,18,17,17,17,17,16,16,16,16,15,15,15,15,14,14,13,13,13,12,12,12,12,11,11,10,10,9,9,9,9,8,8,8,7,7,6,6,6,6,5,5,5,5,4,4,4,4,3,3,3,3,3,2,2,2,2,1,1,1,1,1,1,1
                };
//                for (int i = 0; i < data.length; i++) {
//                    data[i] = i;
//                }
                ecgDrawingGraphView.sampleRate = data.length;
                ecgDrawingGraphView.appendPoints(data);
            }
        }, 0, 1000);
    }

}